package com.jie.other.jetpack.paging.db

import androidx.paging.PagingSource
import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import com.jie.other.jetpack.paging.bean.Repo

@Dao
interface RepoDao {

    /**
     * 查询所有仓库
     */
    @Query("select * from repo order by stars desc")
    fun selectAll(): PagingSource<Int, Repo>

    /**
     * 插入仓库列表
     */
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insertList(repoList : List<Repo>)

    /**
     * 删除所有仓库
     */
    @Query("delete from repo")
    suspend fun deleteAll()

}